package com.Dec_Five;

public class Solution45 {

    public int jump(int[] nums) {
        //if (nums.length==1) return 1;
        int cnt=0,rightMost=0,end=0;
        for (int i = 0; i < nums.length-1; i++) {
            rightMost=Math.max(rightMost,i+nums[i]);
            if (i==end)
            {
                end=rightMost;
                cnt++;
            }
        }
        return cnt;
    }

    public static void main(String[] args) {
        Solution45 solution45=new Solution45();
        System.out.println(solution45.jump(new int[]{2,3,1,1,4}));
    }

}
